package mate.managers
{	
	import mx.core.Application;
	import mx.printing.FlexPrintJob;	
	import vfc.views.PrintDetailsView;
	import vfc.views.PrintView;
	
	public class PrintManager
	{
		public function printHTML(htmlText:String):void
		{
			var printJob:FlexPrintJob = new FlexPrintJob();
			if(printJob.start())
			{
				var printView:PrintView = new PrintView();
				printView.width = printJob.pageWidth;
				printView.height = printJob.pageHeight;
				printView.htmlText = htmlText;
				printView.validateNow();

				Application.application.addChild(printView);				
				
				printJob.addObject(printView);
				
				Application.application.removeChild(printView); 
			}
			printJob.send();
		}
		
		/**
		 * Blake Eaton
		 * 10/01/2008
		 * Added to fix Issue 7: SanJose08 - Print Enhancements
		 * 
		 * @param htmlText Used to print contact information for the 
		 *                 food bank.
		 * 
		 */
		public function printDetails(htmlText:String):void
		{			
			var printDetailsView:PrintDetailsView = 
				new PrintDetailsView();
			printDetailsView.htmlText = htmlText;
			
			// Make the printDetailsView invisible so that it 
			// it is not displayed on the screen when
			// Application.application.addChild(printDetailsView);
			// is called.
			printDetailsView.visible = false;
			
			// Add the printDetailsView to the application so that
			// it will be initialized. Once the Yahoo Map is loaded
			// in the printDetailsViews, the printDetailsView will 
			// be printed.
			Application.application.addChild(printDetailsView);
		}
	}
}